package com.example.smartstart.controller;

import com.example.smartstart.entity.AwardRecord;
import com.example.smartstart.entity.MapRecord;
import com.example.smartstart.model.Result;
import com.example.smartstart.service.IAwardRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dlx
 * @since 2024-07-22
 */
@RestController
@RequestMapping("awardRecord/")
public class AwardRecordController {

    @Autowired
    private IAwardRecordService iAwardRecordService;

    // 增加记录
    @PostMapping("addRecord")
    public Result addRecord(@RequestBody AwardRecord awardRecord){
        awardRecord.setCreateTime(LocalDateTime.now());
        Boolean result = iAwardRecordService.save(awardRecord);
        if (result){
            return Result.success();
        }else {
            return Result.error("操作失败");
        }
    }

}
